package com.chunfeng.mypen.controller;

import com.chunfeng.mypen.entity.ExamRecoding;
import com.chunfeng.mypen.result.JsonRequest;
import com.chunfeng.mypen.service.ExamRecodingService;
import com.chunfeng.mypen.vo.ExamRecodingVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description: 考试历史记录控制层
 * @author: 小雷
 * @createTime: 2023-11-14 00:23:47
 */
@Slf4j
@RestController
@RequestMapping("/examRecoding")
@Api(value = "考试历史记录控制层", tags = "考试记录访问接口")
public class ExamRecodingController {

    @Autowired
    private ExamRecodingService examRecodingService;

    /**
     * 条件查询所有考试记录
     *
     * @param examRecoding 考试记录实体类，包含所有查询条件
     * @return JSON
     */
    @GetMapping
    @ApiOperation(value = "分类筛选考试记录信息")
    public JsonRequest<List<ExamRecodingVo>> lookExamRecoding(
            @ApiParam(value = "考试记录信息", required = true)
            ExamRecoding examRecoding) {
        return examRecodingService.lookExamRecoding(examRecoding);
    }

    /**
     * 新增考试记录
     *
     * @param examRecoding 考试记录实体类
     * @return
     */
    @PostMapping
    @ApiOperation(value = "新增考试记录信息")
    public JsonRequest<Integer> addExamRecoding(@ApiParam(value = "考试记录信息", required = true)
                                                @RequestBody ExamRecoding examRecoding) {
        return examRecodingService.addExamRecoding(examRecoding);
    }

    /**
     * 修改试卷信息
     *
     * @param examRecoding 需要修改的实体类
     * @return
     */
    @PutMapping
    @ApiOperation(value = "修改试卷记录信息")
    public JsonRequest<Integer> updateExamRecoding(@ApiParam(value = "修改的试卷历史记录信息", required = true)
                                                   @RequestBody ExamRecoding examRecoding) {
        return examRecodingService.updateExamRecoding(examRecoding);
    }

    /**
     * 删除试卷记录信息
     *
     * @param ids 需要删除的试卷记录id
     * @return
     */
    @DeleteMapping
    @ApiOperation(value = "删除试卷记录")
    public JsonRequest<Integer> deleteExamRecoding(@ApiParam(value = "删除试卷历史的id", required = true)
                                                   @RequestBody List<String> ids) {
        return examRecodingService.deleteExamRecoding(ids);
    }
}
